package com.theme.passport.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.theme.common.mvc.utils.PageUtils;
import com.theme.common.mvc.utils.Query;
import com.theme.passport.dao.SysFriendlyLinkDao;
import com.theme.passport.entity.SysFriendlyLinkEntity;
import com.theme.passport.service.SysFriendlyLinkService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("sysFriendlyLinkService")
public class SysFriendlyLinkServiceImpl extends ServiceImpl<SysFriendlyLinkDao, SysFriendlyLinkEntity> implements SysFriendlyLinkService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String keyword = (String) params.get("key");
        IPage<SysFriendlyLinkEntity> page = this.page(
                new Query<SysFriendlyLinkEntity>().getPage(params),
                new QueryWrapper<SysFriendlyLinkEntity>()
                        .like(StringUtils.isNotBlank(keyword), "name", keyword)
        );
        return new PageUtils(page);
    }

}